# This defines the compiler and standard ways to use it
CXX = g++
CXXFLAGS = -Wall -Wno-deprecated -m64 -pthread -O

# These are the sources, and computed object and header files
SRC = util.cc math.cc jobqueue.cc interpret.cc allocator.cc economy.cc graphdl.cc tokenizer.cc lexicon.cc suffixindex.cc integerarray.cc dataset.cc thing.cc sync.cc file.cc restaurant.cc server.cc corpus.cc timer.cc ads.cc intsequences.cc function-model.cc objects.cc problem.cc bitarray.cc hashthing.cc
INC = $(addsuffix .h, $(basename $(SRC)))
OBJ = $(addsuffix .o, $(basename $(SRC)))
OBJDEBUG = $(addsuffix .debug.o, $(basename $(SRC)))

# Pattern rule making .o files from .cc
%.o : %.cc
	$(CXX) $(CXXFLAGS) -c $<

# Pattern rule making .o files from .cc
%.debug.o : %.cc
	$(CXX) $(CXXFLAGSDEBUG) -c -o $@ $< 

# This is the standard command line runnable
#in: $(OBJ) in.o
#	$(CXX) $(CXXFLAGS) $(OBJ) in.o -o $@

# This is the standard command line runnable
ec: $(OBJ)
	$(CXX) $(CXXFLAGS) $(OBJ) -o $@

# This is the standard command line runnable
debug: $(OBJDEBUG)
	$(CXX) $(CXXFLAGSDEBUG) $(OBJDEBUG) -o ec.debug

Makefile: depend
-include depend

depend: $(SRC) $(INC)
	$(CXX) -MM $(CXXFLAGS) $(SRC) > depend

.PHONY: clean all
clean:
	rm -f $(OBJ) $(OBJDEBUG) in.o

all: ec debug

